﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace ShenMaPrint
{
    public partial class Form6 : Form
    {
        [DllImport("user32.dll")]
        public static extern int MessageBoxTimeoutA(IntPtr hWnd, string msg, string Caps, int type, int Id, int time);//引用DLL
       
        Form1 f;
        public Form6(Form1 f1)
        {
            InitializeComponent();
            f = f1;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("确认打印？", "请确认！", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
            {
                if (textBox3.Text != "")
                {
                    string code = textBox3.Text;
                    string datanow = "";
                    if (textBox4.Text == "" || textBox4.Text == null)
                    {
                        datanow = DateTime.Today.ToString("yyyy-MM-dd");
                    }
                    else
                    {
                        datanow = textBox4.Text;
                    }
                    string Nowkind = "";
                    if (textBox1.Text == "" || textBox1.Text == null)
                    {
                        Nowkind = INIFileHelper.ReadIniValue("Setting", "Nowkind", Application.StartupPath + @"\Setting.ini").Trim();
                    }
                    else
                    {
                        Nowkind = textBox1.Text;
                    }


                    f.PrintLabel(code, datanow, "计划时间：", "胶种：" + Nowkind);
                    Form1.f6 = null;
                    f.GetInfo();
                    this.Close();
                }
                else
                {
                    MessageBoxTimeoutA((IntPtr)0, "未输入栈板编码，请重试！", "提示", 0, 0, 3000);
                }
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Form1.f6 = null;
            this.Close();
        }

        private void Form6_Load(object sender, EventArgs e)
        {

        }
    }
}
